package com.vip.dao.shop.domain;


import com.vip.base.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 购物车对象 shop_car
 * 
 * @author user
 */
@Data
@Entity
@Table(name = "shopCar")
public class ShopCar extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    public ShopCar(Long userId) {
        this.userId = userId;
    }  

    /** 购物车id */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long carId;


    @Column
    private Long userId;

    /** 最大可装数量 */
    @Column
    private Long maxNumber;

    /** 商品数量 */
    @Column
    private Long totleNumber;

    @Column
    private String comms;

    public ShopCar() {

    }


//    @OneToMany
//    @JoinTable(name="CarComm",joinColumns={@JoinColumn(name="commId")},
//            inverseJoinColumns={@JoinColumn(name="shopCarId")}))

//    @OneToMany
//    private List<ShopComm> comms = new ArrayList<>();






    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("carId", getCarId())
            .append("maxNumber", getMaxNumber())
            .append("totleNumber", getTotleNumber())
            .toString();
    }
}
